package com.example.myapplication;

import android.content.Intent;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import android.view.View;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.RadioGroup;
import android.widget.RadioButton;
import android.widget.Toast;
import android.widget.Button;

public class ThirdActivity3 extends AppCompatActivity {
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.diaochawenjuan);
        Button bt_send;
        CheckBox checkBox1,checkBox2,checkBox3,checkBox4,checkBox5;
        checkBox1=findViewById(R.id.checkBox1);
        checkBox2=findViewById(R.id.checkBox2);
        checkBox3=findViewById(R.id.checkBox3);
        checkBox4=findViewById(R.id.checkBox4);
        checkBox5=findViewById(R.id.checkBox5);
        checkBox1.setOnCheckedChangeListener(onchangedlistener);
        checkBox2.setOnCheckedChangeListener(onchangedlistener);
        checkBox3.setOnCheckedChangeListener(onchangedlistener);
        checkBox4.setOnCheckedChangeListener(onchangedlistener);
        checkBox5.setOnCheckedChangeListener(onchangedlistener);
        bt_send=findViewById(R.id.button_check);
        bt_send.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Toast.makeText(ThirdActivity3.this,"提交成功啦！",Toast.LENGTH_LONG).show();

                Intent intent = new Intent(ThirdActivity3.this, SecondActivity2.class);
                startActivity(intent);
            }
        });
    }
    private CompoundButton.OnCheckedChangeListener onchangedlistener = new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            int id=compoundButton.getId();
            CheckBox checkBox=findViewById(id);
            if(checkBox.isChecked())
                Toast.makeText(ThirdActivity3.this,"您选择了"+checkBox.getText().toString(),Toast.LENGTH_LONG).show();
        }
    };
}
